#include "config.h"

void lenet_c2(
    dtype din[C2_IN_CH][C2_IN_SIZE][C2_IN_SIZE],
    dtype ker[C2_OUT_CH][C2_IN_CH][C2_KER_SIZE][C2_KER_SIZE],
    dtype bias[C2_OUT_CH],
    dtype dout[C2_OUT_CH][C2_OUT_SIZE][C2_OUT_SIZE]
){

    for (int index_out_ch = 0; index_out_ch < C2_OUT_CH; index_out_ch++){
        for (int i = 0; i < C2_OUT_SIZE; i++){
            for (int j = 0; j < C2_OUT_SIZE; j++){
                dtype tmp = 0;
                // dout[index_out_ch][i][j] = bias[index_out_ch];
                for (int index_in_ch = 0; index_in_ch < C2_IN_CH; index_in_ch++){
                    for (int k_i = 0; k_i < C2_KER_SIZE; k_i++){
                        for (int k_j = 0; k_j < C2_KER_SIZE; k_j++){
                            tmp +=  din[index_in_ch][i+k_i][j+k_j] *
                                    // ker[index_out_ch][index_in_ch][C2_KER_SIZE-1-k_i][C2_KER_SIZE-1-k_j]);
                                    ker[index_out_ch][index_in_ch][k_i][k_j];
                        }
                    }
                }
                dout[index_out_ch][i][j] = RELU(tmp + bias[index_out_ch]);
            }
        }
    }   
}